<!-- 管理员用户组新增和编辑页面 -->
<extend name="Public/baseConf" />
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-4">
	        <h2>访问授权</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li><a href="{:U('AuthManager/index')}">授权管理</a></li>
	            <li class="active"><strong>访问授权</strong></li>
	        </ol>
	    </div>
	    <div class="col-lg-6">
    		<div class="title-action">
           	<select name="group" class="form-control">
				<volist name="auth_group" id="vo">
					<option value="{:U('AuthManager/access',array('group_id'=>$vo['id'],'group_name'=>$vo['title']))}" <eq name="vo['id']" value="$this_group['id']">selected</eq> >{$vo.title}</option>
				</volist>
			</select></div>
	    </div>
	    <div class="col-lg-2">
            <div class="title-action">
 				<button class="btn btn-primary ajax-post" type="submit" target-form="auth-form"><i class="fa fa-check"></i>保存</button>
	            <a class="btn btn-warning" type="submit" href="{:U('index')}"><i class="fa fa-reply"></i>返回</a>
            </div>
        </div>
	</div> 
</block>
<block name="body">
	<div class="row">
	    <div class="col-lg-12">
		<div class="tabs-container">
				<ul class="nav nav-tabs"> 
					<li class="active" ><a href="#tabs-1"><i class="blue fa  fa-folder-open  bigger-110"></i>访问授权</a></li>
		            <li><a href="{:U('AuthManager/category',array('group_name'=>I('group_name') ,'group_id'=> I('group_id')))}"><i class="blue fa fa-barcode  bigger-110"></i>分类授权</a></li>
					<li><a href="{:U('AuthManager/user',array('group_name'=>I('group_name') ,'group_id'=> I('group_id')))}"><i class="blue fa fa-user  bigger-110"></i>成员授权</a></li>
				</ul>
				<div  class="tab-content" >
					 <div id="tab-1" class="tab-pane active">
					 <div class="panel-body">
					 <!-- 访问授权 --> 
					 <form action="{:U('AuthManager/writeGroup')}" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
						<input type="hidden" name="id" value="{$this_group.id}" />
						<volist name="node_list" id="node" >
							<dl class="widget-box">
								<dt class="hd">
									<div class="checkbox checkbox-success">
                                		<input id="{$node.title}" name="rules[]" type="checkbox" value="<?php echo $main_rules[$node['url']] ?>" class="auth_rules rules_all" />
                                           <label class="text-navy" for="{$node.title}"><strong>{$node.title}管理</strong></label>
                                       </div>
								</dt>
								<div class="widget-body">
									<dd class="bd"  style="height:auto!important;">
										<present name="node['child']">
										<volist name="node['child']" id="child" >
			                                   <div class="rule_check">
													<div class="checkbox checkbox-warning" <notempty name="child['tip']">title='{$child.tip}'</notempty>>
														&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
														<input id="{$node.title}{$child.title}" name="rules[]" type="checkbox" value="<?php echo $auth_rules[$child['url']] ?>" class="ace auth_rules rules_row" />
			                                            <label class="text-warning" for="{$node.title}{$child.title}"><strong>{$child.title}</strong></label>
			                                        </div>
			                                      <notempty name="child['operator']">
			                                          <span class="child_row" style="height:auto!important;">
			                                              <volist name="child['operator']" id="op">
															 		<div class="checkbox checkbox-default" <notempty name="op['tip']">title='{$op.tip}'</notempty>>
															 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															 		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
															 			<input id="{$node.title}{$child.title}{$op.title}" name="rules[]"  type="checkbox" value="<?php echo $auth_rules[$op['url']] ?>" class="auth_rules" >
							                                            <label for="{$node.title}{$child.title}{$op.title}">{$op.title} </label>
							                                        </div>
			                                              </volist>
			                                          </span>
			                                      </notempty>
						                    </div>
										</volist>
										</present>
									</dd>
								</div><!-- /.widget-body -->
							</dl>
							<div class="hr-line-dashed"></div>
						</volist>
				    </form> 
				    </div>
				    </div>
				 </div>
			</div>
		</div>
	</div>
</block>
<block name="script">
	<script type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
	<link rel="stylesheet" type="text/css" href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
	<script type="text/javascript" charset="utf-8">
	    +function($){
	        var rules = [{$this_group.rules}];
	        $('.auth_rules').each(function(){
	            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
	                $(this).prop('checked',true);
	            }
	            if(this.value==''){
	                $(this).closest('span').remove();
	            }
	        });
	        //全选节点
	        $('.rules_all').on('change',function(){
	            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
	        });
	        $('.rules_row').on('change',function(){
	            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
	        });
	        $('.checkbox').each(function(){
	            $(this).qtip({
	                content: {
	                    text: $(this).attr('title'),
	                    title: $(this).text()
	                },
	                position: {
	                    my: 'bottom center',
	                    at: 'top center',
	                    target: $(this)
	                },
	                style: {
	                    classes: 'qtip-dark',
	                    tip: {
	                        corner: true,
	                        mimic: false,
	                        width: 10,
	                        height: 10
	                    }
	                }
	            });
	        });
	        $('select[name=group]').change(function(){
				location.href = this.value;
	        });
	    }(jQuery);
	</script>
</block>
